<template>
  <div class="app-container">
    <el-form :model="selectForm" ref="selectForm" :inline="true">
      <el-form-item label="备件名称">
        <el-input
          v-model="selectForm.replacementPartName"
          placeholder="请输入备件名称"
          clearable
          size="small"
          @keyup.enter.native="getList"
        />
      </el-form-item>
      <el-form-item label="使用单位">
        <el-input
          v-model="selectForm.buildingUser"
          placeholder="请输入使用单位"
          clearable
          size="small"
          @keyup.enter.native="getList"
        />
      </el-form-item>
    </el-form>
    <el-form :model="selectForm" ref="selectForm" :inline="true" label-width="120px">
      <el-form-item>
        <el-button size="mini" type="primary" icon="el-icon-search" @click="getList">搜索</el-button>
        <!--        <el-button size="mini" type="success" icon="el-icon-plus" @click="add"-->
        <!--                   v-hasPermi="['system:brandInformation:add']">新增-->
        <!--        </el-button>-->
      </el-form-item>
    </el-form>


    <el-table :data="list.rows" border v-loading="loading">
      <el-table-column align="center" type="index" label="序号" width="55"/>
      <el-table-column label="类别" prop="category" align="center" width="150px">
      </el-table-column>
      <el-table-column label="备件名称" prop="replacementPartName" align="center" width="200px"/>
      <el-table-column label="规格类型" prop="specificationsModels" align="center" width="100px"/>
      <el-table-column label="单位" prop="replacementPartUnit" align="center"/>
      <el-table-column label="数量" prop="number" align="center" :show-overflow-tooltip="true"/>
      <el-table-column label="需要程度" prop="needDegree" align="center"/>
      <el-table-column label="用途" prop="purpose" align="center" :show-overflow-tooltip="true"/>
      <el-table-column label="使用单位" prop="buildingUser" align="center"></el-table-column>
      <el-table-column label="备注" prop="remark" align="center"/>
      <el-table-column label="创建时间" prop="createTime" align="center" width="200px"></el-table-column>
      <el-table-column label="操作" align="center" fixed="right" width="200px">
        <template slot-scope="scope">
          <!--          <el-button size="mini" type="success" icon="el-icon-edit" @click="edit(scope.row)"-->
          <!--                     v-hasPermi="['system:brandInformation:edit']">修改-->
          <!--          </el-button>-->
          <el-button size="mini" type="danger" icon="el-icon-delete" @click="del(scope.row)"
                     v-hasPermi="['system:brandInformation:delete']">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total="list.total?list.total:0"
      :page.sync="selectForm.pageNum"
      :limit.sync="selectForm.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {list,del} from "@/api/replacementPartPlan";

export default {
  name: "index",
  data() {
    return {
      list: {},
      //领用记录入参
      selectForm: {
        replacementPartName: '',
        buildingUser: '',
        pageNum: 1,
        pageSize: 10,
      },
      loading: false,
    }
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {
      let row = await list(this.selectForm);
      this.list = row;
    },
    del(row) {
      this.$confirm('确定删除吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        await del(row.id);
        this.$message.success('删除成功');
        await this.getList();
      }).catch(() => {
        this.$message.info('取消删除')
      });
    },
  }
}
</script>

<style scoped>

</style>
